
#include "Bag.hpp"


/**
 * 模块ID
 */
itemInfo::itemInfo() {
	guid = "" ;
	entry = 0 ;
	bagType = 0 ;
	slot = 0 ;
	stack = 0 ;
	entry = 0 ;
	bind = 0 ;
	color = 0 ;
	quality = 0 ;
	unEffectTime = 0 ;
	baseAttributeTypeLength = 0 ;
	privateBaseAttributeTypeLength = 0 ;
	privateBaseAttributeType = NULL ;
	baseAttributeValueLength = 0 ;
	privateBaseAttributeValueLength = 0 ;
	privateBaseAttributeValue = NULL ;
	bonusAttributeTypeLength = 0 ;
	privateBonusAttributeTypeLength = 0 ;
	privateBonusAttributeType = NULL ;
	bonusAttributeValueLength = 0 ;
	privateBonusAttributeValueLength = 0 ;
	privateBonusAttributeValue = NULL ;
	durability = 0 ;
	json = "" ;
} ;

uint32_t itemInfo::baseAttributeTypeMaxLength() { return this->privateBaseAttributeTypeLength ; }
int32_t* itemInfo::baseAttributeType() { return this->privateBaseAttributeType ; }
void itemInfo::mallocbaseAttributeType( uint32_t length ) { 
	if( this->privateBaseAttributeType ) delete[] this->privateBaseAttributeType ;
	this->baseAttributeTypeLength = length ;
	this->privateBaseAttributeTypeLength = length ;
	this->privateBaseAttributeType = new int32_t[length] ;
}

uint32_t itemInfo::baseAttributeValueMaxLength() { return this->privateBaseAttributeValueLength ; }
int32_t* itemInfo::baseAttributeValue() { return this->privateBaseAttributeValue ; }
void itemInfo::mallocbaseAttributeValue( uint32_t length ) { 
	if( this->privateBaseAttributeValue ) delete[] this->privateBaseAttributeValue ;
	this->baseAttributeValueLength = length ;
	this->privateBaseAttributeValueLength = length ;
	this->privateBaseAttributeValue = new int32_t[length] ;
}

uint32_t itemInfo::bonusAttributeTypeMaxLength() { return this->privateBonusAttributeTypeLength ; }
int32_t* itemInfo::bonusAttributeType() { return this->privateBonusAttributeType ; }
void itemInfo::mallocbonusAttributeType( uint32_t length ) { 
	if( this->privateBonusAttributeType ) delete[] this->privateBonusAttributeType ;
	this->bonusAttributeTypeLength = length ;
	this->privateBonusAttributeTypeLength = length ;
	this->privateBonusAttributeType = new int32_t[length] ;
}

uint32_t itemInfo::bonusAttributeValueMaxLength() { return this->privateBonusAttributeValueLength ; }
int32_t* itemInfo::bonusAttributeValue() { return this->privateBonusAttributeValue ; }
void itemInfo::mallocbonusAttributeValue( uint32_t length ) { 
	if( this->privateBonusAttributeValue ) delete[] this->privateBonusAttributeValue ;
	this->bonusAttributeValueLength = length ;
	this->privateBonusAttributeValueLength = length ;
	this->privateBonusAttributeValue = new int32_t[length] ;
}

itemInfo::~itemInfo() {
	if( privateBaseAttributeType ) delete[] privateBaseAttributeType ;
	if( privateBaseAttributeValue ) delete[] privateBaseAttributeValue ;
	if( privateBonusAttributeType ) delete[] privateBonusAttributeType ;
	if( privateBonusAttributeValue ) delete[] privateBonusAttributeValue ;
} ;

CMsgTyped* itemInfo::Serialize( CMsgTyped * msgTyped ) {
	msgTyped->SetString( guid.c_str( ) ) ;
	msgTyped->SetInt( entry ) ;
	msgTyped->SetInt( bagType ) ;
	msgTyped->SetInt( slot ) ;
	msgTyped->SetInt( stack ) ;
	msgTyped->SetInt( entry ) ;
	msgTyped->SetInt( bind ) ;
	msgTyped->SetInt( color ) ;
	msgTyped->SetInt( quality ) ;
	msgTyped->SetInt( unEffectTime ) ;
	{
		size_t realLength ; 
		if( baseAttributeTypeLength > privateBaseAttributeTypeLength ) {
			printf( "ERROR --> [%s:%d] 越界访问[%s]\n" , __FILE__ , __LINE__ , "privateBaseAttributeType" ) ;
			realLength = privateBaseAttributeTypeLength ;
		} else {
			realLength = baseAttributeTypeLength ;
		}
		msgTyped->SetInt( realLength ) ;
		for( size_t i = 0 ; i < realLength ; ++i ) {
	msgTyped->SetInt( privateBaseAttributeType[i] ) ;
		}
	}
	{
		size_t realLength ; 
		if( baseAttributeValueLength > privateBaseAttributeValueLength ) {
			printf( "ERROR --> [%s:%d] 越界访问[%s]\n" , __FILE__ , __LINE__ , "privateBaseAttributeValue" ) ;
			realLength = privateBaseAttributeValueLength ;
		} else {
			realLength = baseAttributeValueLength ;
		}
		msgTyped->SetInt( realLength ) ;
		for( size_t i = 0 ; i < realLength ; ++i ) {
	msgTyped->SetInt( privateBaseAttributeValue[i] ) ;
		}
	}
	{
		size_t realLength ; 
		if( bonusAttributeTypeLength > privateBonusAttributeTypeLength ) {
			printf( "ERROR --> [%s:%d] 越界访问[%s]\n" , __FILE__ , __LINE__ , "privateBonusAttributeType" ) ;
			realLength = privateBonusAttributeTypeLength ;
		} else {
			realLength = bonusAttributeTypeLength ;
		}
		msgTyped->SetInt( realLength ) ;
		for( size_t i = 0 ; i < realLength ; ++i ) {
	msgTyped->SetInt( privateBonusAttributeType[i] ) ;
		}
	}
	{
		size_t realLength ; 
		if( bonusAttributeValueLength > privateBonusAttributeValueLength ) {
			printf( "ERROR --> [%s:%d] 越界访问[%s]\n" , __FILE__ , __LINE__ , "privateBonusAttributeValue" ) ;
			realLength = privateBonusAttributeValueLength ;
		} else {
			realLength = bonusAttributeValueLength ;
		}
		msgTyped->SetInt( realLength ) ;
		for( size_t i = 0 ; i < realLength ; ++i ) {
	msgTyped->SetInt( privateBonusAttributeValue[i] ) ;
		}
	}
	msgTyped->SetInt( durability ) ;
	msgTyped->SetString( json.c_str( ) ) ;
	return msgTyped ;
} ;

CMsgTyped* itemInfo::Unserialize( CMsgTyped* msgTyped ) {
	guid = msgTyped->StringVal() ;
	entry = msgTyped->IntVal() ;
	bagType = msgTyped->IntVal() ;
	slot = msgTyped->IntVal() ;
	stack = msgTyped->IntVal() ;
	entry = msgTyped->IntVal() ;
	bind = msgTyped->IntVal() ;
	color = msgTyped->IntVal() ;
	quality = msgTyped->IntVal() ;
	unEffectTime = msgTyped->IntVal() ;
	privateBaseAttributeTypeLength = msgTyped->IntVal( ) ;
	baseAttributeTypeLength = privateBaseAttributeTypeLength ;
	privateBaseAttributeType = new int32_t[privateBaseAttributeTypeLength] ;
	for( size_t i = 0 ; i < privateBaseAttributeTypeLength ; ++i ) {
	privateBaseAttributeType[i] = msgTyped->IntVal() ;
	}
	privateBaseAttributeValueLength = msgTyped->IntVal( ) ;
	baseAttributeValueLength = privateBaseAttributeValueLength ;
	privateBaseAttributeValue = new int32_t[privateBaseAttributeValueLength] ;
	for( size_t i = 0 ; i < privateBaseAttributeValueLength ; ++i ) {
	privateBaseAttributeValue[i] = msgTyped->IntVal() ;
	}
	privateBonusAttributeTypeLength = msgTyped->IntVal( ) ;
	bonusAttributeTypeLength = privateBonusAttributeTypeLength ;
	privateBonusAttributeType = new int32_t[privateBonusAttributeTypeLength] ;
	for( size_t i = 0 ; i < privateBonusAttributeTypeLength ; ++i ) {
	privateBonusAttributeType[i] = msgTyped->IntVal() ;
	}
	privateBonusAttributeValueLength = msgTyped->IntVal( ) ;
	bonusAttributeValueLength = privateBonusAttributeValueLength ;
	privateBonusAttributeValue = new int32_t[privateBonusAttributeValueLength] ;
	for( size_t i = 0 ; i < privateBonusAttributeValueLength ; ++i ) {
	privateBonusAttributeValue[i] = msgTyped->IntVal() ;
	}
	durability = msgTyped->IntVal() ;
	json = msgTyped->StringVal() ;
	return msgTyped ;
} ;

const uint16_t DeleteItem::messageId = 3 ;
DeleteItem::DeleteItem() {
	guid = "" ;
} ;

DeleteItem::~DeleteItem() {
} ;

CMsgTyped* DeleteItem::Unserialize( CMsgTyped* msgTyped ) {
	guid = msgTyped->StringVal() ;
	return msgTyped ;
} ;

const uint16_t BagInit::messageId = 0 ;

BagInit::BagInit() {
	bagType = 0 ;
	itemCount = 0 ;
	itemsLength = 0 ;
	privateItemsLength = 0 ;
	privateItems = NULL ;
} ;

uint32_t BagInit::itemsMaxLength() { return this->privateItemsLength ; }
itemInfo* BagInit::items() { return this->privateItems ; }
void BagInit::mallocitems( uint32_t length ) { 
	if( this->privateItems ) delete[] this->privateItems ;
	this->itemsLength = length ;
	this->privateItemsLength = length ;
	this->privateItems = new itemInfo[length] ;
}

BagInit::~BagInit() {
	if( privateItems ) delete[] privateItems ;
} ;

CMsgTyped* BagInit::Serialize( CMsgTyped * msgTyped ) {
	msgTyped->SetInt( bagType ) ;
	msgTyped->SetInt( itemCount ) ;
	{
		size_t realLength ; 
		if( itemsLength > privateItemsLength ) {
			printf( "ERROR --> [%s:%d] 越界访问[%s]\n" , __FILE__ , __LINE__ , "privateItems" ) ;
			realLength = privateItemsLength ;
		} else {
			realLength = itemsLength ;
		}
		msgTyped->SetInt( realLength ) ;
		for( size_t i = 0 ; i < realLength ; ++i ) {
	privateItems[i].Serialize( msgTyped ) ;
		}
	}
	return msgTyped ;
} ;

const uint16_t BagUpdate::messageId = 1 ;

BagUpdate::BagUpdate() {
	bagType = 0 ;
	itemCount = 0 ;
	itemsLength = 0 ;
	privateItemsLength = 0 ;
	privateItems = NULL ;
} ;

uint32_t BagUpdate::itemsMaxLength() { return this->privateItemsLength ; }
itemInfo* BagUpdate::items() { return this->privateItems ; }
void BagUpdate::mallocitems( uint32_t length ) { 
	if( this->privateItems ) delete[] this->privateItems ;
	this->itemsLength = length ;
	this->privateItemsLength = length ;
	this->privateItems = new itemInfo[length] ;
}

BagUpdate::~BagUpdate() {
	if( privateItems ) delete[] privateItems ;
} ;

CMsgTyped* BagUpdate::Serialize( CMsgTyped * msgTyped ) {
	msgTyped->SetInt( bagType ) ;
	msgTyped->SetInt( itemCount ) ;
	{
		size_t realLength ; 
		if( itemsLength > privateItemsLength ) {
			printf( "ERROR --> [%s:%d] 越界访问[%s]\n" , __FILE__ , __LINE__ , "privateItems" ) ;
			realLength = privateItemsLength ;
		} else {
			realLength = itemsLength ;
		}
		msgTyped->SetInt( realLength ) ;
		for( size_t i = 0 ; i < realLength ; ++i ) {
	privateItems[i].Serialize( msgTyped ) ;
		}
	}
	return msgTyped ;
} ;

const uint16_t BagDelete::messageId = 2 ;

BagDelete::BagDelete() {
	bagType = 0 ;
	itemCount = 0 ;
	itemsLength = 0 ;
	privateItemsLength = 0 ;
	privateItems = NULL ;
} ;

uint32_t BagDelete::itemsMaxLength() { return this->privateItemsLength ; }
int32_t* BagDelete::items() { return this->privateItems ; }
void BagDelete::mallocitems( uint32_t length ) { 
	if( this->privateItems ) delete[] this->privateItems ;
	this->itemsLength = length ;
	this->privateItemsLength = length ;
	this->privateItems = new int32_t[length] ;
}

BagDelete::~BagDelete() {
	if( privateItems ) delete[] privateItems ;
} ;

CMsgTyped* BagDelete::Serialize( CMsgTyped * msgTyped ) {
	msgTyped->SetInt( bagType ) ;
	msgTyped->SetInt( itemCount ) ;
	{
		size_t realLength ; 
		if( itemsLength > privateItemsLength ) {
			printf( "ERROR --> [%s:%d] 越界访问[%s]\n" , __FILE__ , __LINE__ , "privateItems" ) ;
			realLength = privateItemsLength ;
		} else {
			realLength = itemsLength ;
		}
		msgTyped->SetInt( realLength ) ;
		for( size_t i = 0 ; i < realLength ; ++i ) {
	msgTyped->SetInt( privateItems[i] ) ;
		}
	}
	return msgTyped ;
} ;

